<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function f() {
            var Id = document.getElementById('a');
            var Id1 = document.getElementById('b');
            var split = Id.value.split(",");
            var i = 0;
            while (i <= split.length) {
                if (Id1 == split[i]) {
                    alert(Id1+"在数组"+split+"的索引位置是"+i);
                }
            }
        }
    </script>
</head>
<body>
字符串数组格式：(a,哈哈，3)：<input type="text" id="a" value="">要查找的元素：<input type="text" id="b" value="">
<input type="button" onclick="f()" value="开始查找">
</body>
</html>